package com.yanqu.road.entity.player;

import com.alibaba.fastjson.JSON;
import com.yanqu.road.entity.DataObject;
import com.yanqu.road.utils.property.Property;

import java.math.BigInteger;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;

public class UserHistoryAttribute extends DataObject {

    private long userId;

    private BigInteger ability = BigInteger.ZERO;

    private BigInteger earnSpeed = BigInteger.ZERO;

    private long qualification;

    private BigInteger activityStartAbility = BigInteger.ZERO;

    private BigInteger activityStartEarnSpeed = BigInteger.ZERO;

    private long activityStartQualification;

    private BigInteger crossActivityStartAbility = BigInteger.ZERO;

    private BigInteger crossActivityStartEarnSpeed = BigInteger.ZERO;

    private long crossActivityStartQualification;

    private Map<Integer, Integer> rankActivityTopThreeTotalTimesMap = new ConcurrentHashMap<>();
    private Map<Integer, Integer> crossRankActivityTopThreeTotalTimesMap = new ConcurrentHashMap<>();

    private BigInteger topBuildingEarnSpeed = BigInteger.ZERO;     //历史最高店铺赚速

    private Property musicRoomTimerAmountReward = new Property(); // 妙音坊时辰累计奖励
    private String musicRoomGuide = ""; // 妙音坊引导

    /**
     * 实力积分更新时间
     */
    private long monthAbilityUpdateTime;
    /**
     * 实力积分
     */
    private BigInteger monthAbility = BigInteger.ZERO;

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        if (this.userId != userId) {
            this.userId = userId;
            setUpdateOption();
        }
    }

    public BigInteger getAbility() {
        return ability;
    }

    public void setAbility(BigInteger ability) {
        if(!Objects.equals(this.ability, ability)) {
            this.ability = ability;
            setUpdateOption();
        }
    }

    public BigInteger getEarnSpeed() {
        return earnSpeed;
    }

    public void setEarnSpeed(BigInteger earnSpeed) {
        if(!Objects.equals(this.earnSpeed, earnSpeed)) {
            this.earnSpeed = earnSpeed;
            setUpdateOption();
        }
    }

    public long getQualification() {
        return qualification;
    }

    public void setQualification(long qualification) {
        if(this.qualification != qualification) {
            this.qualification = qualification;
            setUpdateOption();
        }
    }

    public BigInteger getActivityStartAbility() {
        return activityStartAbility;
    }

    public void setActivityStartAbility(BigInteger activityStartAbility) {
        if(!Objects.equals(this.activityStartAbility, activityStartAbility)) {
            this.activityStartAbility = activityStartAbility;
            setUpdateOption();
        }
    }

    public BigInteger getActivityStartEarnSpeed() {
        return activityStartEarnSpeed;
    }

    public void setActivityStartEarnSpeed(BigInteger activityStartEarnSpeed) {
        if(!Objects.equals(this.activityStartEarnSpeed, activityStartEarnSpeed)) {
            this.activityStartEarnSpeed = activityStartEarnSpeed;
            setUpdateOption();
        }
    }

    public long getActivityStartQualification() {
        return activityStartQualification;
    }

    public void setActivityStartQualification(long activityStartQualification) {
        if(this.activityStartQualification != activityStartQualification) {
            this.activityStartQualification = activityStartQualification;
            setUpdateOption();
        }
    }

    public BigInteger getCrossActivityStartAbility() {
        return crossActivityStartAbility;
    }

    public void setCrossActivityStartAbility(BigInteger crossActivityStartAbility) {
        if(!Objects.equals(this.crossActivityStartAbility, crossActivityStartAbility)) {
            this.crossActivityStartAbility = crossActivityStartAbility;
            setUpdateOption();
        }
    }

    public BigInteger getCrossActivityStartEarnSpeed() {
        return crossActivityStartEarnSpeed;
    }

    public void setCrossActivityStartEarnSpeed(BigInteger crossActivityStartEarnSpeed) {
        if(!Objects.equals(this.crossActivityStartEarnSpeed, crossActivityStartEarnSpeed)) {
            this.crossActivityStartEarnSpeed = crossActivityStartEarnSpeed;
            setUpdateOption();
        }
    }

    public long getCrossActivityStartQualification() {
        return crossActivityStartQualification;
    }

    public void setCrossActivityStartQualification(long crossActivityStartQualification) {
        if(this.crossActivityStartQualification != crossActivityStartQualification) {
            this.crossActivityStartQualification = crossActivityStartQualification;
            setUpdateOption();
        }
    }

    public void setRankActivityTopThreeTotalTimesMap(Map<Integer, Integer> rankActivityTopThreeTotalTimesMap) {
        this.rankActivityTopThreeTotalTimesMap = rankActivityTopThreeTotalTimesMap;
        setUpdateOption();
    }

    public String getRankActivityTopThreeTotalTimesMapJson(){
        return JSON.toJSONString(rankActivityTopThreeTotalTimesMap);
    }

    public int getRankActivityTopThreeTotalTimes(int rankActivityType){
        if(rankActivityTopThreeTotalTimesMap.containsKey(rankActivityType)){
            return rankActivityTopThreeTotalTimesMap.get(rankActivityType);
        }
        return 0;
    }

    public void addRankActivityTopThreeTotalTimes(int rankActivityType){
        int times = getRankActivityTopThreeTotalTimes(rankActivityType);
        times++;
        rankActivityTopThreeTotalTimesMap.put(rankActivityType, times);
        setUpdateOption();
    }

    public void setCrossRankActivityTopThreeTotalTimesMap(Map<Integer, Integer> crossRankActivityTopThreeTotalTimesMap) {
        this.crossRankActivityTopThreeTotalTimesMap = crossRankActivityTopThreeTotalTimesMap;
        setUpdateOption();
    }

    public int getCrossRankActivityTopThreeTotalTimes(int rankActivityType){
        if(crossRankActivityTopThreeTotalTimesMap.containsKey(rankActivityType)){
            return crossRankActivityTopThreeTotalTimesMap.get(rankActivityType);
        }
        return 0;
    }

    public String getCrossRankActivityTopThreeTotalTimesMapJson(){
        return JSON.toJSONString(crossRankActivityTopThreeTotalTimesMap);
    }

    public void addCrossRankActivityTopThreeTotalTimes(int rankActivityType){
        int times = getCrossRankActivityTopThreeTotalTimes(rankActivityType);
        times++;
        crossRankActivityTopThreeTotalTimesMap.put(rankActivityType, times);
        setUpdateOption();
    }

    public BigInteger getTopBuildingEarnSpeed() {
        return topBuildingEarnSpeed;
    }

    public void setTopBuildingEarnSpeed(BigInteger topBuildingEarnSpeed) {
        if(!Objects.equals(this.topBuildingEarnSpeed, topBuildingEarnSpeed)) {
            this.topBuildingEarnSpeed = topBuildingEarnSpeed;
            setUpdateOption();
        }
    }

    public Property getMusicRoomTimerAmountReward() {
        return musicRoomTimerAmountReward;
    }

    public void setMusicRoomTimerAmountReward(Property musicRoomTimerAmountReward) {
        this.musicRoomTimerAmountReward = musicRoomTimerAmountReward;
        setUpdateOption();
    }

    public void addMusicRoomTimerAmountReward(Property amount) {
        this.musicRoomTimerAmountReward.addProperty(amount);
        setUpdateOption();
    }

    public String getMusicRoomGuide() {
        return musicRoomGuide;
    }

    public void setMusicRoomGuide(String musicRoomGuide) {
        this.musicRoomGuide = musicRoomGuide;
    }
}
